﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Utils.Menu;

namespace DevDemo
{
    public partial class SplitButtonDemo : Form
    {
        public SplitButtonDemo()
        {
            InitializeComponent();
        }

        private void SplitButtonDemo_Load(object sender, EventArgs e)
        {
            CreateDropDownControl();
        }

        private void CreateDropDownControl()
        {
            DropDownButton btn = new DropDownButton();
            btn.Text = "Click here";
            btn.DropDownControl = CreateDXPopupMenu();
            btn.Location = new Point(10, 20);
            Controls.Add(btn);
        }

        private DXPopupMenu CreateDXPopupMenu()
        {
            DXPopupMenu menu = new DXPopupMenu();
            menu.Items.Add(new DXMenuItem("Item", OnItemClick));
            menu.Items.Add(new DXMenuCheckItem("CheckItem", false, null, OnItemClick));
            DXSubMenuItem subMenu = new DXSubMenuItem("SubMenu");
            subMenu.Items.Add(new DXMenuItem("SubItem", OnItemClick));
            menu.Items.Add(subMenu);
            return menu;
        }

        private void OnItemClick(object sender, EventArgs e)
        {
            DXMenuItem item = sender as DXMenuItem;
            XtraMessageBox.Show(item.Caption);
        }

        
    }
}
